/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package flight.model;

import java.io.FileNotFoundException;
import java.util.List;

/**
 *
 * @author tam
 */
public class FlightBufferedTextDataSource extends FlightTextDataSource{
    List<Flight> flights;
    public FlightBufferedTextDataSource(String file) throws FileNotFoundException{
        super(file);
        flights = super.getAll();
    }

    @Override
    public Flight getById(int id) {
        for(Flight f:flights){
            if(f.id == id)
                return f;
        }
        return null;
    }

    @Override
    public int getNoOfFlights() {
        return flights.size();
    }

    @Override
    public List<Flight> getAll(){
        return flights;
    }
}
